package com.tiancheng.onecode.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: kellen
 * @Description: 商户状态枚举
 * @Date: create in 2024/12/12 14:31
 */
@Getter
@AllArgsConstructor
public enum MerchantStatusEnums implements BaseEnum<Integer> {
    init(0, "等待平台审核"),
    platform_pass(1, "平台审核通过（待银商审核）"),
    normal(2, "正常（可用）"),
    platform_not_pass(3, "平台审核不通过"),
    abnormal(4, "异常"),
    bank_not_pass(5, "银行审核不通过"),
    abnormal_recovery(6, "异常恢复中"),
    bank_material_supplement(7, "银行进件信息待补充"),
    stop(8, "停用"),
    delete(9, "删除"),
    ;

    private final Integer code;
    private final String name;

    public static Optional<MerchantStatusEnums> getByCode(Integer code){
        return Arrays.stream(MerchantStatusEnums.values()).filter(m -> m.getCode().equals(code)).findFirst();
    }

    public static String getDescByCode(Integer code){
        Optional<MerchantStatusEnums> first = Arrays.stream(MerchantStatusEnums.values()).filter(m -> m.getCode().equals(code)).findFirst();
        return first.isEmpty()?"":first.get().getName();
    }
}
